package com.byzk.p2p.admin.red.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.byzk.p2p.admin.base.util.PageInfo;
import com.byzk.p2p.admin.red.dao.RedEnveDao;
import com.byzk.p2p.admin.red.vo.RedEnveVo;

/**
 * 红包service		suker.zhou
 * @author suker.zhou
 *
 */
@Service
public class RedEnveService {
	
	@Autowired
	private RedEnveDao redEnveDao;

	
	/**
	 * 红包新增修改
	 * @param fundRecord
	 * @return
	 */
	public Integer saveOrUpdate(RedEnveVo record){
		if(record.getId()==null){
			return redEnveDao.insert(record);
		}else{
			return redEnveDao.update(record);
		}
	}
	
	/**
	 * 红包记录
	 * @param limit
	 * @param index
	 * @param record
	 * @return
	 */
	public PageInfo<RedEnveVo> list(RedEnveVo vo){
		int count=redEnveDao.count(vo);
		List<RedEnveVo> recordList = redEnveDao.list(vo);
		PageInfo<RedEnveVo> page=	new PageInfo<RedEnveVo>(count, vo.getIndex() , vo.getLimit());
		page.setPageList(recordList);
		return page;
	}
	
	/**
	 * 红包详情
	 * @param id
	 * @return
	 */
	public RedEnveVo detail(Integer id){
		RedEnveVo vo=redEnveDao.selectByPrimaryKey(id);
		return vo;
	}
	
	
	
	
}